/**
 * select下拉菜单
 */
import tem from './index.html'
module.exports = angular.module('directive.uiSelect', []).directive('uiSelect', function() {
    return {
        restrict: 'AE',
        template: tem,
        replace: true,
        scope: {
            ngModel: '=',
            errorTis: '<',
        },
        controller:function ($scope) {
            var _this = this
            _this.val = function(){
                return $scope.ngModel
            }
            console.log('$scope.ngModel', $scope.ngModel)
            $scope.$on('value', function(e,newVal) {
                console.log('watch-value', newVal)
                $scope.name = newVal.name
                $scope.ngModel = newVal.value
            })
        },
        transclude:true,
        link:function(scope,el){
            if(!scope.ngModel) {
                scope.name = '请选择'
            }
        }
    }
}).name